﻿
Public Class bytesString
    Inherits bytesbase(Of String)

    Public Overrides Sub frombytes(ByVal b As bytes)
        If Not b Is Nothing Then
            d = encoding.utf8.GetString(+b)
        End If
    End Sub

    Public Overrides Function tobytes() As bytes
        If Not d Is Nothing Then
            Return New bytes(encoding.utf8.GetBytes(d))
        Else
            Return Nothing
        End If
    End Function

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal i As String)
        MyBase.New(i)
        If isemptystring(d) Then
            copy(d, emptyString)
        End If
    End Sub

    Public Overloads Shared Widening Operator CType(ByVal this As String) As bytesString
        Return New bytesString(this)
    End Operator
End Class
